package com.iiifi.kite.rocketmq.configuration;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;

import com.iiifi.kite.rocketmq.core.AbstractMqProducer;
import com.iiifi.kite.rocketmq.core.AbstractMqPushConsumer;
import com.iiifi.kite.rocketmq.properties.RocketMqProperties;

/**
 * RocketMQ配置文件
 *
 * @author kite@iiifi.com 花朝
 */
@Configuration
@AutoConfigureAfter({AbstractMqProducer.class, AbstractMqPushConsumer.class})
@EnableConfigurationProperties(RocketMqProperties.class)
public class RocketMqAutoConfiguration implements ApplicationContextAware {
    protected RocketMqProperties mqProperties;

    @Autowired
    public void setMqProperties(RocketMqProperties mqProperties) {
        this.mqProperties = mqProperties;
    }

    protected ConfigurableApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = (ConfigurableApplicationContext) applicationContext;
    }

}

